package com.fare.taluo.vo.crawl.result;
/**
 * 封装即时抓取结果的一个类
 * 配合页面json可以恒方便的取出各种信息
 * @author Administrator
 *
 */
public class CrawlResult {
	
	public static final int NO_FLIGHTINFO=0;//没有航班信息
	public static final int HAS_FLIGHTINFO=1;//有航班信息
	public static final int NO_TICKETS=2;//票卖完
	public static final int CRAWLERROR=3;//抓取失败，有错误
	private int state=CrawlResult.NO_FLIGHTINFO;//状态信息
	private Object data=null;//最终结果,如果抓取错误，可以在data里面放入错误的信息字符串等等
	private String depCity;//出发城市
	private String depCityCode;
	private String arrCity;//到达城市
	private String arrCityCode;
	private String flightDate;//起飞日期
	private String endDate;//截至日期
	private String[] flightTimes; //航班时间点，(上午，中午，下午，晚上)
	private String carrierKey;//运营商key 如CA等
	
	private CrawlResult(){}; 
	public static  CrawlResult newInstance(String depCity,
			String depCityCode, String arrCity, String arrCityCode,
			String flightDate, String endDate, String[] flightTimes,
			String carrierKey,int state, Object data) {
		CrawlResult c=new CrawlResult();
		c.state =generateState(state);
		c.data = data;
		c.depCity = depCity;
		c.depCityCode = depCityCode;
		c.arrCity = arrCity;
		c.arrCityCode = arrCityCode;
		c.flightDate = flightDate;
		c.endDate = endDate;
		c.flightTimes = flightTimes;
		c.carrierKey = carrierKey;
		return c;
	}
	
	private static int generateState(int state){
		int s=CrawlResult.CRAWLERROR;
		switch(state){
			case CrawlResult.NO_FLIGHTINFO:
			case CrawlResult.NO_TICKETS:
			case CrawlResult.HAS_FLIGHTINFO:
			case CrawlResult.CRAWLERROR:
				s=state;
				break;
			default:
				s=CrawlResult.CRAWLERROR;
		}
		return s;
	}
	
	public Object getData() {
		return data;
	}
	public void setData(Object data) {
		this.data = data;
	}
	public int getState() {
		return state;
	}
	public void setState(int state) {
		this.state = state;
	}
	public String getDepCity() {
		return depCity;
	}
	public void setDepCity(String depCity) {
		this.depCity = depCity;
	}
	public String getDepCityCode() {
		return depCityCode;
	}
	public void setDepCityCode(String depCityCode) {
		this.depCityCode = depCityCode;
	}
	public String getArrCity() {
		return arrCity;
	}
	public void setArrCity(String arrCity) {
		this.arrCity = arrCity;
	}
	public String getArrCityCode() {
		return arrCityCode;
	}
	public void setArrCityCode(String arrCityCode) {
		this.arrCityCode = arrCityCode;
	}
	public String getFlightDate() {
		return flightDate;
	}
	public void setFlightDate(String flightDate) {
		this.flightDate = flightDate;
	}
	public String getEndDate() {
		return endDate;
	}
	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}
	public String[] getFlightTimes() {
		return flightTimes;
	}
	public void setFlightTimes(String[] flightTimes) {
		this.flightTimes = flightTimes;
	}
	public String getCarrierKey() {
		return carrierKey;
	}
	public void setCarrierKey(String carrierKey) {
		this.carrierKey = carrierKey;
	}

	
 }
